package com.ccp.dev.qbdms.enums;

import com.ccp.dev.core.util.CollectionUtil;

import java.util.List;

/**
 * Created by zzy on 2020/7/28.
 *
 * @Author zzy
 * @Date 2020/7/28
 * @describe 院级状态码对应院级状态码,用于集中部署时过滤数据以及状态回显
 */
public enum HospitalLevelStateCodeEnum {

    /**待报集团*/
    DBJT("12","待报集团", CollectionUtil.newList()),
    /**报集团审批中*/
    SPZ("13","报集团审批中",CollectionUtil.newList()),
    /**报集团审批未通过*/
    WTG("14","报集团审批未通过",CollectionUtil.newList()),
    /**报集团中*/
    BJTZ("15","报集团中",CollectionUtil.newList()),
    /**报集团成功  对应集团一系列状态码,系统等级为院级时出现这些状态码表示该数据状态就是报集团成功 */
    BJTCG("16","报集团成功",CollectionUtil.newList("21","22","23","24","28","32")),
    /**报集团失败*/
    BJTSB("17","报集团失败",CollectionUtil.newList()),
    /**集团退回*/
    JTTH("18","集团退回",CollectionUtil.newList()),
    /**院退回中*/
    YTHZ("19","院退回中",CollectionUtil.newList()),
    /**院退回失败*/
    YTHSB("20","院退回失败",CollectionUtil.newList()),
    /**院内待审批*/
    YNDSP("25","院内待审批",CollectionUtil.newList()),
    /**院内审批中*/
    YNSPZ("26","院内审批中",CollectionUtil.newList()),
    /**院内审批未通过*/
    YNSPWTG("27","院内审批未通过",CollectionUtil.newList()),
    /** 院级无需上报,由集团退回 */
    WSSB("31","无需上报",CollectionUtil.newList()),
    /** 院无需上报中 */
    SBZ("33","无需上报中",CollectionUtil.newList()),
    /** 院无需上报失败 */
    SBSB("29","无需上报失败",CollectionUtil.newList()),

    /** 集团退回待修改中 */
    THDXGZ("35","退回待修改中",CollectionUtil.newList()),
    /** 集团退回待修改失败 */
    THDXGSB("37","退回待修改失败",CollectionUtil.newList()),
    /** 集团退回待修改 系统等级为院级时出现这些状态码表示该数据状态就是退回待修改  */
    THDXG("39","退回待修改",CollectionUtil.newList("10"));



    /**
     * 获取全部的状态码
     *  @auth zzy
     * @return
     */
    public static List<String> getAllCode(){
        List<String> list = CollectionUtil.newList();
        for (HospitalLevelStateCodeEnum value : HospitalLevelStateCodeEnum.values()) {
            list.add(value.code);
            list.addAll(value.relatedCode);
        }
        return list;
    }

    /**
     * 根据状态code获取状态name
     * @param code
     * @return
     */
    public static String getNameByCode(String code){
        for (HospitalLevelStateCodeEnum e : HospitalLevelStateCodeEnum.values()) {
            if (e.code.equals(code)) {
                return e.name;
            }
            if (e.relatedCode.contains(code)) {
                return e.name;
            }
        }
        return "";
    }

    /**
     * 根据关联code查找对应的状态code
     * @param code
     * @return
     */
    public static String getCodeByRelatedCode(String code){
        for (HospitalLevelStateCodeEnum e : HospitalLevelStateCodeEnum.values()) {
            if (e.code.equals(code)) {
                return e.code;
            }
            if (e.relatedCode.contains(code)) {
                return e.code;
            }
        }
        return "";
    }

    /**
     * 根据code查找对应的relatedcode
     * @author zzy
     * @param code
     * @return
     */
    public static List<String> getRelatedCodeByCode(String code){
        List<String> list = CollectionUtil.newList();
        for (HospitalLevelStateCodeEnum e : HospitalLevelStateCodeEnum.values()) {
            if (e.getCode().equals(code)) {
                list.addAll(e.getRelatedCode());
                break;
            }
        }
        return list;
    }


    /**状态码*/
    private String code;
    /**状态名称*/
    private String name;
    /**对应上级状态码*/
    private List<String> relatedCode;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<String> getRelatedCode() {
        return relatedCode;
    }

    public void setRelatedCode(List<String> relatedCode) {
        this.relatedCode = relatedCode;
    }

    private HospitalLevelStateCodeEnum(String code, String name, List<String> relatedCode) {
        this.code = code;
        this.name = name;
        this.relatedCode = relatedCode;
    }
}
